<?php
/**
 * Class representation of the HTML <input type="text" /> tag. It can be added to containers.
 *
 * @author Niels Janssen
 * @since 2008-07-08
 * @package Form.Elements
 */
class InputText extends FormElement {

	/**
	 * Constructor for the TextField class, passes variables to the FormElement constructor.
	 *
	 * @param String $name
	 * @param String $label
	 * @param String $value
	 * @param String class
	 */
	public function __construct( $name, $label = '', $value = '', $class = '', $properties = array( ) )
	{
		parent::__construct( $name, array_merge( array( 'value' => $value, 'label' => $label, 'class' => $class ), $properties ) );
	}

	/**
	 * @see FormElement::__toString()
	 */
	public function __toString() {
		return '
			<div class="form inputtext '.( $this->getProperty("class") != '' ? $this->getProperty("class") : '' ). ' ' . ( $this->inAJAXMode() || !empty( $this->errorMessage ) ? 'error' : '' ) . '">
				<label for="' . ( $this->getFormName() != '' ? $this->getFormName() . '_' : '' ) . $this->name . '">' . $this->getProperty("label") . '</label>
				<input  type="text" name="' . ( $this->getFormName() != '' ? $this->getFormName() . '_' : '' ) . $this->name . '" id="' . ( $this->getFormName() != '' ? $this->getFormName() . '_' : '' ) . $this->name . '" value="' . $this->value . '"' . ( $this->getProperty( 'tabindex' ) ? ( ' tabindex="' . $this->getProperty( 'tabindex' ) . '"' ) : '' ) . ' size="'.( $this->getProperty("size") != '' ? $this->getProperty("size") : '' ).'" />
				' . ( $this->getProperty('sidenote') != '' ? '<em>' . $this->getProperty('sidenote') . '</em>' : '' ) .
				'' . ( $this->inAJAXMode() || !empty( $this->errorMessage ) ? '<div class="error' . ( $this->inAJAXMode() ? ' ajax' : '' ) . ( !empty( $this->errorMessage ) ? ' not-empty' : '' ) . '" id="' . ( $this->getFormName() != '' ? $this->getFormName() . '_' : '' ) . $this->name . '_error">' . $this->errorMessage . '</div>' : '' ) . '</div>';
	}
}

?>